import Vue from 'vue';
const Drag = Vue.directive('drag', {
  bind (el, binding) {
    el.onmousedown = function (e) {
      var keyx = e.pageX - el.offsetLeft;
      var keyy = e.pageY - el.offsetTop;

      document.onmousemove = function (e) {
        el.style.position = 'absolute';
        el.style.left = e.pageX - keyx + 'px';
        el.style.top = e.pageY - keyy + 'px';
      };

      document.onmouseup = function () {
        document.onmousemove = document.onmousedown = null;
      };

      e.preventDefault();
    };
  }
});
export default {Drag};
